package org.example.game.history;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/07/28 10:38
 */
public class Solution4082 {

    public static void main(String[] args) {
        System.out.println(Math.sqrt(7));
        System.out.println(Math.sqrt(11));

        System.out.println(new Solution4082().nonSpecialCount(5, 7));
        System.out.println(new Solution4082().nonSpecialCount(1, 16));
    }

    public int nonSpecialCount(int l, int r) {
        int count = 0;
        int start = (int) Math.ceil(Math.sqrt(l));
        int end = (int) Math.floor(Math.sqrt(r));
        for(int i=start;i<=end;i++){
            //i是质数
            if(isPrimeNumber(i)){
                count++;
            }
        }

        return r-l+1- count;
    }

    public static boolean isPrimeNumber(int num) {
        if (num <= 1) {
            return false;
        }
        for (int i = 2; i <= Math.sqrt(num); i++) {
            if (num % i == 0) {
                return false;
            }
        }
        return true;
    }
}
